"""Regress the distance between anchor point and boundary directly"""
_base_ = [
    "../../../../_base_/datasets/face_license_4gpu_addjson.py",
    #  "../../../../_base_/datasets/face_license_visual_anchor.py",
    "../../../../_base_/default_runtime.py",
]
model = dict(
    type="GFL",
    pretrained="/workspace/volume/wangxianzhuo-data/modelzoo/repvgg_s-f9b3ea19.pth",
    backbone=dict(
        type="RepVGG",
        num_blocks=[2, 4, 8, 2],
        stem_channels=16,
        out_indices=0,
        width_multiplier=[0.5, 0.5, 0.5, 0.5],
        deploy=False,
    ),
    neck=dict(
        type="FPN_NIL_slim_deconv",
        in_channels=[32, 64, 128, 256],
        out_channels=64,
        start_level=0,
        end_level=3,
        add_extra_convs="on_output",
        num_outs=3,
        deconv_param=[2, 2, 0],
        method="method2",
    ),
    bbox_head=dict(
        type="GFLSinOut_S4downsample_shift_coupling",
        norm_cfg=dict(type="BN"),
        num_classes=2,
        num_ins=3,
        in_channels=64,
        stacked_convs=3,
        feat_channels=64,
        anchor_generator=dict(
            type="AnchorGenerator",
            ratios=[1.0],
            octave_base_scale=2,
            scales_per_octave=1,
            strides=[4, 8, 16],
        ),
        inference_anchor_generator=dict(
            type="AnchorGenerator",
            ratios=[1.0],
            octave_base_scale=2,
            scales_per_octave=1,
            strides=[8, 8, 16],
        ),
        loss_cls=dict(
            type="QualityFocalLoss", use_sigmoid=True, beta=2.0, loss_weight=1.0
        ),
        loss_shift=dict(type="MSELoss", loss_weight=0.5),
        loss_bbox=dict(type="GIoULoss", loss_weight=2.0),
    ),
)
# training and testing settings
atss_result_path = "/workspace/volume/wangxianzhuo-data/data/facecar_visual/anchor/method2_s4downsample_shift_weight1.0"
train_cfg = dict(
    assigner=dict(
        type="ATSSAssigner",
        topk=9,
        thre_method="mean+var",
        #  print_num_anchor=True,
        #  print_bbox_in_img=True,
        saved_path=atss_result_path,
        #  print_num_gt_without_anchor_center=True,
    ),
    allowed_border=-1,
    pos_weight=-1,
    debug=False,
)
test_cfg = dict(
    nms_pre=1000,
    min_bbox_size=0,
    score_thr=0.05,
    nms=dict(type="nms", iou_thr=0.6),
    max_per_img=100,
)
# optimizer
optimizer = dict(type="SGD", lr=0.01, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
# learning policy
lr_config = dict(
    policy="step", warmup="linear", warmup_iters=500, warmup_ratio=0.001, step=[16, 22]
)
total_epochs = 24

seed = 166
find_unused_parameters = True
